package com.akillitavsiye.datastore;

import com.akillitavsiye.User;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.DAOBase;

public class UserDAO extends DAOBase {

	private static final UserDAO instance = new UserDAO();

	static {
		ObjectifyService.register(User.class);
	}

	public static UserDAO getInstance() {
		return instance;
	}

	public void delete(User user) {
		Objectify ofy = ObjectifyService.begin();
		ofy.delete(user);
	}

	public User get(String username) {
		Objectify ofy = ObjectifyService.begin();
		User user = ofy.get(User.class, username);

		return user;
	}

	public void put(User user) {
		Objectify ofy = ObjectifyService.begin();
		ofy.put(user);
	}
}
